package com.itheima.dao;

import com.itheima.pojo.Role;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

public interface RoleDao {

    @Select("select r.*  from t_role r,t_user_role ur where r.id=ur.role_id and ur.user_id=#{userId}")
    @Results({
            @Result(column = "id",property = "id",id = true),
            @Result(column = "name",property = "name"),
            @Result(column = "keyword",property = "keyword"),
            @Result(column = "description",property = "description"),
            @Result(column = "id",property = "permissions",many = @Many(select = "com.itheima.dao.PermissionDao.findPermissionByRoleId")),
    })
   Set<Role> findRolesByUserId(Integer userId);
}
